<?php
namespace Admin\Models\ims;
use Admin\Models\BaseModel;
use Helpers\Main;

class XHImsBoxOut extends BaseModel
{

    /**
     *
     * @var integer
     * @Primary
     * @Column(type="integer", length=11, nullable=false)
     */
    public $iBOutId;
    public $sYear;

    /**
     * @var integer
     * create by xjq 20180612
     */
    public $iChargeMode;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iProdId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iTypeId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iBoxId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iOutNum;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $iType;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iSchoolId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bDelete;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tCreateDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tLastModifyDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iLastModifyUserId;

    /**
     * @var integer
     * create by dale 20180404 关联planContent
     */
    public $iBPCId;


    /**
     * 出售价
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     *
     *  create by dale 20180424
     */
    public $iOutPrice;

    /**
     * 领用关联id
     * @var integer
     * create by xjq 20180530
     */
    public $iLRId;

    /**
     * 出库备注
     * @var string
     * create by xjq 20180621
     */
    public $sRemark;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSource("XHIms_BoxOut");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHIms_BoxOut';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHImsBoxOut[]|XHImsBoxOut|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHImsBoxOut|\Phalcon\Mvc\Model\ResultInterface
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }


    /**
     * 新建之前的操作
     *
     * @return bool|void
     * create by xjq 20180621
     */
    public function beforeCreate()
    {
        $date = date('Y-m-d H:i:s', time());
        $id   = Main::getLoginUserInfo('userId');
        $this->tCreateDate   = $date;
        $this->iCreateUserId = $this->iCreateUserId ?: $id;
        $this->tLastModifyDate = $date;
        $this->iLastModifyUserId = $this->iLastModifyUserId ?: $id;
    }

}
